<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/report.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div>
    </div>
    <div class="content">
      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
        <div id="tab-general">
          <div id="languages" class="htabs">
            <?php foreach ($languages as $language) { ?>
            <a href="#language<?php echo $language['language_id']; ?>"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
            <?php } ?>
          </div>
          <?php foreach ($languages as $language) { ?>
          <div id="language<?php echo $language['language_id']; ?>">
            <table class="form">           
              <tr>
                <td><span class="required">*</span> <?php echo $entry_title; ?> <?php echo $sort_order; ?>:</td>
                <td><textarea name="question_description[<?php echo $language['language_id']; ?>][title]" row="7" cols="70"><?php echo isset($question_description[$language['language_id']]) ? $question_description[$language['language_id']]['title'] : ''; ?></textarea>
                  <?php if (isset($error_title[$language['language_id']])) { ?>
                  <span class="error"><?php echo $error_title[$language['language_id']]; ?></span>
                  <?php } ?></td>
              </tr>              
              <tr>
                <td><?php echo $entry_lable; ?></td>
                <td><textarea name="question_description[<?php echo $language['language_id']; ?>][lable]" row="7" cols="70"><?php echo isset($question_description[$language['language_id']]) ? $question_description[$language['language_id']]['lable'] : ''; ?></textarea>
                  <?php if (isset($error_lable[$language['language_id']])) { ?>
                  <span class="error"><?php echo $error_lable[$language['language_id']]; ?></span>
                  <?php } ?></td>
              </tr>
              <tr>
                <td><?php echo $entry_value; ?></td>
                <td><textarea type="text" name="question_description[<?php echo $language['language_id']; ?>][value]" row="7" cols="70"><?php echo isset($question_description[$language['language_id']]) ? $question_description[$language['language_id']]['value'] : ''; ?></textarea>
                  <?php if (isset($error_value[$language['language_id']])) { ?>
                  <span class="error"><?php echo $error_value[$language['language_id']]; ?></span>
                  <?php } ?></td>
              </tr>
              <tr>
                <td><?php echo $entry_default; ?></td>
                <td><textarea name="question_description[<?php echo $language['language_id']; ?>][default]" row="7" cols="70"><?php echo isset($question_description[$language['language_id']]) ? $question_description[$language['language_id']]['default'] : ''; ?></textarea>
                  <?php if (isset($error_default[$language['language_id']])) { ?>
                  <span class="error"><?php echo $error_default[$language['language_id']]; ?></span>
                  <?php } ?></td>
              </tr>
              <tr>
				<td><?php echo $entry_required; ?></td>
				<td><select name="question_required">
					<?php if(isset($question_required)) {?>
						<?php if($question_required) {?>
					<option value="1" selected><?php echo $text_yes; ?></option>
					<option value="0"><?php echo $text_no; ?></option>
						<?php } else { ?>
					<option value="1"><?php echo $text_yes; ?></option>
					<option value="0" selected><?php echo $text_no; ?></option>	
						<?php } ?>
					<?php } else { ?>
					<option value="1"><?php echo $text_yes; ?></option>
					<option value="0"><?php echo $text_no; ?></option>
					<?php } ?>
					</select></td>
			  </tr>              
              <tr>
                <td><span class="required">*</span> <?php echo $entry_description; ?></td>
                <td><textarea name="question_description[<?php echo $language['language_id']; ?>][description]" id="description<?php echo $language['language_id']; ?>"><?php echo isset($question_description[$language['language_id']]) ? $question_description[$language['language_id']]['description'] : ''; ?></textarea>
                  <?php if (isset($error_description[$language['language_id']])) { ?>
                  <span class="error"><?php echo $error_description[$language['language_id']]; ?></span>
                  <?php } ?></td>
              </tr>
            </table>
          </div>
          <?php } ?>
        </div>
        <div id="tab-data">
          <table class="form">
			<tr>
                <td><span class="required">*</span> <?php echo $entry_survey_id; ?></td>
                <td><select name="survey_id" id="survey_id">
                  <?php foreach ($surveys as $survey) { ?>
                  <?php if ($survey['survey_id'] == $survey_id) { ?>
                  <option value="<?php echo $survey['survey_id']; ?>" selected="selected"><?php echo $survey['title']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $survey['survey_id']; ?>"><?php echo $survey['title']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select> <?php if(isset($button_set_survey)) {?>&nbsp; <a href="javascript:void(0);" onclick="setDefaultSurvey()" class="button"><span><?php echo $button_set_survey; ?></span></a><?php } ?>
                <?php if (isset($error_survey_id)) { ?>
                  <span class="error"><?php echo $error_survey_id; ?></span>
                  <?php } ?></td></td>
            </tr>
            <tr>
                <td><span class="required">*</span> <?php echo $entry_qtype; ?></td>
                <td><?php foreach ($all_qtypes as $each_row) { ?>
                  <?php if ($each_row['type'] == $qtype) { ?>
                  <input name="qtype" type="radio" value="<?php echo $each_row['type']; ?>" checked /><?php echo $each_row['name']; ?>
                  <?php } else { ?>
                  <input name="qtype" type="radio" value="<?php echo $each_row['type']; ?>" /><?php echo $each_row['name']; ?>
                  <?php } ?>
                  <?php } ?> <?php if(isset($button_set_type)) {?>&nbsp; <a href="javascript:void(0);" onclick="setDefaultType()" class="button"><span><?php echo $button_set_type; ?></span></a><?php } ?>
                <?php if (isset($error_qtype)) { ?>
                  <span class="error"><?php echo $error_qtype; ?></span>
                  <?php } ?></td></td>
            </tr>
            <tr>
                <td><span class="required">*</span> <?php echo $entry_qformat; ?></td>
                <td><?php foreach ($all_qformats as $each_row) { ?>
                  <?php if ($each_row['type'] == $qformat) { ?>
                  <input name="qformat" type="radio" value="<?php echo $each_row['type']; ?>" checked /><?php echo $each_row['name']; ?>
                  <?php } else { ?>
                  <input name="qformat" type="radio" value="<?php echo $each_row['type']; ?>" /><?php echo $each_row['name']; ?>
                  <?php } ?>
                  <?php } ?> <?php if(isset($button_set_format)) {?>&nbsp; <a href="javascript:void(0);" onclick="setDefaultFormat()" class="button"><span><?php echo $button_set_format; ?></span></a><?php } ?>
                <?php if (isset($error_qformat)) { ?>
                  <span class="error"><?php echo $error_qformat; ?></span>
                  <?php } ?></td></td>
            </tr>
            <tr>
              <td><?php echo $entry_qnum; ?></td>
              <td><input type="text" name="qnum" value="<?php echo $qnum; ?>" size="10" /></td>
            </tr>            
            <tr>
              <td><?php echo $entry_sort_order; ?></td>
              <td><input type="text" name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
            </tr>                       
            <tr>
              <td><?php echo $entry_keyword; ?></td>
              <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td>
            </tr>
            <tr>
              <td><?php echo $entry_status; ?></td>
              <td><select name="status">
                  <?php if ($status) { ?>
                  <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                  <option value="0"><?php echo $text_disabled; ?></option>
                  <?php } else { ?>
                  <option value="1"><?php echo $text_enabled; ?></option>
                  <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                  <?php } ?>
                </select></td>
            </tr>
          </table>
        </div>
        <input type="hidden" name="question_store[]" value="0" />
        <input type="hidden" name="set_default_survey" id="set_default_survey" value="" />        
        <input type="hidden" name="set_default_type" id="set_default_type" value="" />        
        <input type="hidden" name="set_default_format" id="set_default_format" value="" />        
      </form>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
function setDefaultSurvey () {
	var survey_id = $('#survey_id').attr('value');
	$('#set_default_survey').attr('value', survey_id);
}

function setDefaultType () {
	var qtype = $('input[name=\'qtype\']:checked').val();
	$('#set_default_type').attr('value', qtype);
}

function setDefaultFormat () {
	var qformat = $('input[name=\'qformat\']:checked').val();
	$('#set_default_format').attr('value', qformat);
}
//--></script> 
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script> 
<script type="text/javascript"><!--
<?php foreach ($languages as $language) { ?>
CKEDITOR.replace('description<?php echo $language['language_id']; ?>', {
	filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
	filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
<?php } ?>
//--></script> 
<script type="text/javascript"><!--
//$('#tabs a').tabs(); 
$('#languages a').tabs(); 
//--></script> 
<?php echo $footer; ?>